package com.gxa.logistics.controller;

import com.gxa.logistics.common.base.R;
import com.gxa.logistics.common.base.RespResult;
import com.gxa.logistics.domain.dto.WarehouseDTO;
import com.gxa.logistics.domain.vo.WarehouseVO;
import com.gxa.logistics.service.WarehouseService;
import com.gxa.logistics.service.impl.WarehouseServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "仓库管理-仓库设置")
@RequestMapping("/warehouse")
public class WarehouseController {

    @Autowired
    private WarehouseService warehouseService;


    @GetMapping("/selectWarehouse") //浏览与分页
    public RespResult selectWarehouse(@RequestParam int page, @RequestParam int limit) {
        List<WarehouseDTO> warehouseDTOList = warehouseService.selectWarehouse(page, limit);
        return RespResult.success(warehouseDTOList);
    }

    @GetMapping("/selectWarehouseByName") //按名字查询
    public R selectWarehouseByName(@RequestParam String warehouse_name) {

        return R.success(warehouseService.selectWarehouseByName(warehouse_name));
    }

    @PostMapping("/insert") //插入数据
    public Map<String, Object> insert(@RequestBody WarehouseDTO warehouseDTO) {
        return warehouseService.insert(warehouseDTO);
    }
    @PostMapping("/delete") //删除数据
    public Map<String, Object> delete(@RequestParam String warehouse_name) {
        return warehouseService.delete(warehouse_name);
    }
    @PostMapping("/update") //修改
    public Map<String, Object> update(@RequestBody WarehouseDTO warehouseDTO) {
        return warehouseService.update(warehouseDTO);
    }
}
